From: Sebastian Kemper Date: Mon, 5 Nov 2018 19:34:28 +0000 (+0100) Subject: rtpproxy: convert init to procd X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22http:/www.crowdsec.net/%22/%22https:/collectd.org/%22http:/www.crowdsec.net/%22?a=commitdiff_plain;h=a3767c5f00544054ebde80071e217d041e04a7df;p=feed%2Ftelephony.git rtpproxy: convert init to procd Update rtpproxy init script to use procd. Also increases the start priority to 90 (like the hotplug script) to make sure rtpproxy is started before kamailio. Fixes some whitespace issues along the way, too. Signed-off-by: Sebastian Kemper --- diff --git a/net/rtpproxy/files/rtpproxy.init b/net/rtpproxy/files/rtpproxy.init index d1e2b37..32c2940 100644 --- a/net/rtpproxy/files/rtpproxy.init +++ b/net/rtpproxy/files/rtpproxy.init @@ -1,17 +1,34 @@ #!/bin/sh /etc/rc.common # Copyright (C) 2014 CESNET, z.s.p.o +# Copyright (C) 2018 OpenWrt.org -START=99 -RTPPROXY_BIN="/usr/bin/rtpproxy" +START=90 -run_instance(){ - local params="$1" +NAME=rtpproxy +COMMAND="/usr/bin/$NAME" - ${RTPPROXY_BIN} $1 - echo "[INFO] rtpproxy instance $2 has started" +USE_PROCD=1 + +#PROCD_DEBUG=1 + +LOGGER="/usr/bin/logger -t $NAME" +LOG_ERR="$LOGGER -p user.err -s" + +run_instance() { + procd_open_instance + procd_set_param command $COMMAND + procd_append_param command \ + $1 \ + -p "/var/run/$NAME-$2.pid" \ + -f + # forward stderr to logd + procd_set_param stderr 1 + procd_close_instance + + $LOGGER instance $2 has started } -check_param(){ +check_param() { local param="$1" local value="$2" local default_value="$3" @@ -25,7 +42,7 @@ check_param(){ fi } -check_special_param(){ +check_special_param() { local param="$1" if [ "$param" != "" ]; then @@ -46,25 +63,25 @@ handle_instance() { check_param "-s" "$socket" check_param "-l" "$ipaddr" check_param "-6" "$ip6addr" - check_param "-u" "$user" "nobody" + check_param "-u" "$user" "nobody" + check_special_param "$opts" run_instance "$rtpproxy_options" "$site" } -start(){ - config_load rtpproxy - local section="global" +start_service() { + local enabled + + config_load $NAME + config_get_bool enabled global enabled 0 if [ "$enabled" -eq 1 ]; then config_foreach handle_instance instance else - echo "[WARNING] rtpproxy not yet configured. Edit /etc/config/rtpproxy first." + $LOG_ERR service not enabled + $LOG_ERR edit /etc/config/$NAME fi } -stop() { - killall rtpproxy -} -